import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;


public class MapExample {
	
	public void mainmethod(){
		Map<Integer,Integer> hm1 =new HashMap<Integer,Integer>();
		hm1.put(1,100);
		hm1.put(2,200);
		hm1.put(3,300);
		hm1.put(4,400);
		hm1.put(5,500);
		hm1.put(6,600);
		hm1.put(6,700);
		hm1.put(7,500);
		hm1.put(null, 800);
		hm1.put(null, 900);
		hm1.put(8,null);
		hm1.put(9,null);
		hm1.put(null,null);
		
		System.out.println("Get value of 6"+hm1.get(6));
		//iterate the map
		Set<Integer> keys=hm1.keySet();
		for(Integer key:keys){
			System.out.println(hm1.getClass().getName()+"Get value of "+key+"is "+hm1.get(key));
		}
		
		
		System.out.println("HashMap Value hm1:"+hm1);
		System.out.println("Check given value inside the Map:"+hm1.containsValue(200));
		if(hm1.containsValue(100)){
			System.out.println("The hashmap contains value 100");
		} else {
			System.out.println("The hashmap does not contains value 100");
		}
		if(hm1.containsValue("first")){
			System.out.println("The hashmap contains value first");
		} else {
			System.out.println("The hashmap does not contains value first");
		}
		System.out.println("Check given key inside the Map:"+hm1.containsKey(1));
		if(hm1.containsKey(2)){
            System.out.println("The hashmap contains key first");
        } else {
            System.out.println("The hashmap does not contains key first");
        }
        if(hm1.containsKey(7)){
            System.out.println("The hashmap contains key fifth");
        } else {
            System.out.println("The hashmap does not contains key fifth");
        }
		
		System.out.println("Remove given key inside the Map:"+hm1.remove(1));
		System.out.println("Size of the Map:"+hm1.size());
		hm1.values();
		Map<Integer,Integer> hm0 =new HashMap<Integer,Integer>();
		hm1.put(1,100);
		hm1.put(7,700);
		hm1.putAll(hm0);
		//getting value for the given key from hashmap
        Set<Entry<Integer,Integer>> entires = hm1.entrySet();
        for(Entry<Integer,Integer> ent:entires){
            System.out.println(ent.getKey()+" ==> "+ent.getValue());
        }
		
		
		hm1.clear();
		System.out.println("After clear,Size of the Map:"+hm1.size());
		
		hm1=new TreeMap<Integer,Integer>();
		hm1.put(1,100);
		hm1.put(2,200);
		hm1.put(3,300);
		hm1.put(4,400);
		hm1.put(5,500);
		hm1.put(6,600);
		hm1.put(6,700);
		hm1.put(7,500);
		//hm1.put(null, 800);
	//	hm1.put(null, 900);
		hm1.put(8,null);
		hm1.put(9,null);
		//hm1.put(null,null);
		Set<Integer> keys0=hm1.keySet();
		for(Integer key:keys0){
			System.out.println(hm1.getClass().getName()+"Get value of "+key+"is "+hm1.get(key));
		}
		hm1=new LinkedHashMap<Integer,Integer>();
		hm1.put(1,100);
		hm1.put(2,200);
		hm1.put(3,300);
		hm1.put(4,400);
		hm1.put(5,500);
		hm1.put(6,600);
		hm1.put(6,700);
		hm1.put(7,500);
		hm1.put(null, 800);
		hm1.put(null, 900);
		hm1.put(8,null);
		hm1.put(9,null);
		hm1.put(null,null);
		Set<Integer> keyss1=hm1.keySet();
		for(Integer key:keyss1){
			System.out.println(hm1.getClass().getName()+"Get value of "+key+"is "+hm1.get(key));
		}

		Map<Integer,String> hm2=new HashMap<Integer,String>();

		hm2.put(1,"One");
		hm2.put(2,"Two");
		hm2.put(3,"Three");
		hm2.put(4,"Four");
		hm2.put(5,"Five");
		hm2.put(6,"Six");
		hm2.put(7,"");
		 Set<Integer> keys10 = hm2.keySet();
	        for(Integer l:keys10){
	            System.out.println("Integer String HashMap"+l+"==>"+hm2.get(l));
	        }
	    hm2=new TreeMap<Integer,String>();
	    hm2.put(1,"One");
		hm2.put(2,"Two");
		hm2.put(3,"Three");
		hm2.put(4,"Four");
		hm2.put(5,"Five");
		hm2.put(6,"Six");
		hm2.put(7,"");
		 Set<Integer> keys101 = hm2.keySet();
	        for(Integer l:keys101){
	            System.out.println(hm2.getClass().getName()+"Integer String HashMap"+l+"==>"+hm2.get(l));
	        }
	    
	    hm2=new LinkedHashMap<Integer,String>();
	    hm2.put(1,"One");
		hm2.put(2,"Two");
		hm2.put(3,"Three");
		hm2.put(4,"Four");
		hm2.put(5,"Five");
		hm2.put(6,"Six");
		hm2.put(7,"");
		 Set<Integer> keys102 = hm2.keySet();
	        for(Integer l:keys102){
	            System.out.println(hm2.getClass().getName()+"Integer String HashMap"+l+"==>"+hm2.get(l));
	        }
	    
		Map<String,String> hm3=new HashMap<String,String>();
		hm3.put("A","AOne");
		hm3.put("B","BTwo");
		hm3.put("C","CThree");
		hm3.put("D","DFour");
		hm3.put("E","EFive");
		hm3.put("F","FSix");
		hm3.put("", "");
		Set<String> keys11 = hm3.keySet();
        for(String l:keys11){
            System.out.println(hm3.getClass().getName()+"String String HashMap"+l+"==>"+hm3.get(l));
        }
		
        hm3=new TreeMap<String,String>();
        hm3.put("A","AOne");
		hm3.put("B","BTwo");
		hm3.put("C","CThree");
		hm3.put("D","DFour");
		hm3.put("E","EFive");
		hm3.put("F","FSix");
		hm3.put("", "");
		Set<String> keys111 = hm3.keySet();
        for(String l:keys111){
            System.out.println(hm3.getClass().getName()+"String String HashMap"+l+"==>"+hm3.get(l));
        }
        hm3=new LinkedHashMap<String,String>();
        hm3.put("A","AOne");
		hm3.put("B","BTwo");
		hm3.put("C","CThree");
		hm3.put("D","DFour");
		hm3.put("E","EFive");
		hm3.put("F","FSix");
		hm3.put("", "");
		Set<String> keys112 = hm3.keySet();
        for(String l:keys112){
            System.out.println(hm3.getClass().getName()+"String String HashMap"+l+"==>"+hm3.get(l));
        }
        Map<Long,Student> hm4=new HashMap<Long,Student>();
		hm4.put(1L,new Student(1L,"Kishan1"));
		hm4.put(2L,new Student(2L,"Kishan2"));
		hm4.put(3L,new Student(3L,"Kishan3"));
		hm4.put(4L,new Student(4L,"Kishan4"));
		hm4.put(5L,new Student(5L,"Kishan5"));
		hm4.put(6L,new Student(6L,"Kishan6"));
		
		 Set<Long> keys144 = hm4.keySet();
	        for(Long l:keys144){
	            System.out.println(hm4.getClass().getName()+"String String HashMap"+l+"==>"+hm4.get(l));
	        }

	        hm4=new TreeMap<Long,Student>();
	        hm4.put(1L,new Student(1L,"Kishan1"));
			hm4.put(2L,new Student(2L,"Kishan2"));
			hm4.put(3L,new Student(3L,"Kishan3"));
			hm4.put(4L,new Student(4L,"Kishan4"));
			hm4.put(5L,new Student(5L,"Kishan5"));
			hm4.put(6L,new Student(6L,"Kishan6"));
			
			 Set<Long> keys145 = hm4.keySet();
		        for(Long l:keys145){
		            System.out.println(hm4.getClass().getName()+"String String HashMap"+l+"==>"+hm4.get(l));
		        }
			hm4=new LinkedHashMap<Long,Student>();
			hm4.put(1L,new Student(1L,"Kishan1"));
			hm4.put(2L,new Student(2L,"Kishan2"));
			hm4.put(3L,new Student(3L,"Kishan3"));
			hm4.put(4L,new Student(4L,"Kishan4"));
			hm4.put(5L,new Student(5L,"Kishan5"));
			hm4.put(6L,new Student(6L,"Kishan6"));
			
			 Set<Long> keys1 = hm4.keySet();
		        for(Long l:keys1){
		            System.out.println(hm4.getClass().getName()+"String String HashMap"+l+"==>"+hm4.get(l));
		        }
		Map<String,List<Student>> hm5=new HashMap<String,List<Student>>();
		
	}
	

	public static void main(String[] args) {
		MapExample me=new MapExample();
		me.mainmethod();

	}

}
